package com.jugheadzhou.client.service.fallback;

import com.jugheadzhou.client.service.TestRemoteService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 远程调用服务失败处理
 *
 * @author jugheadzhou
 * @date 2021年05月06日
 */
@Slf4j
@Component
public class TestRemoteServiceFallback implements FallbackFactory<TestRemoteService> {

    @Override
    public TestRemoteService create(Throwable throwable) {
        return parameter -> {
            String err = "调用服务[cloud-openfeign-server]发生了未知异常";
            log.error(err + "业务参数: {}", parameter, throwable);
            return err;
        };
    }

}
